<?php
class RM_Admin_ReportsController extends RM_Controller {
    
    public function loadJsonAction(){
        
    }

    public function updateJsonAction(){

        
    }

    public function listJsonAction(){
        $module = new RM_Module_Reports();
        $reports = $module->getAllReports()->toArray();

        $json = new stdClass;
        $json->total = count($reports);
        $json->data = $reports;

        return array(
            'data' => $json
        );
    }

    public function showreportAction(){

        $id =  $this->_getParam('id');

        $reportsDAO = new RM_Reports();
        $reportData = $reportsDAO->getALLbyID($id)->current();

        ob_clean();
        $view = new RM_View();
        $view->assign('report', $reportData);

        $view->addScriptPath(implode(
            DIRECTORY_SEPARATOR,
            array(
                RM_Environment::getConnector()->getRootPath(),
                'RM',
                'userdata',
                'modules',
                'Reports',
                'views',
                'admin',
                'scripts',
            )
        ));

        echo $view->render('templates/'.$reportData->filename.'.phtml');
        die();

    }

}